const charsSource = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];

/** 生成随机字符串 */
export const randomString = (length) => {
  let result = '';
  for (var i = 0; i < length; i++) {
    let index = Math.floor(Math.random() * charsSource.length);
    result += charsSource[index];
  }
  return result;
}

/** 展示错误信息 */
export const showMsg = inputMsg => {
  let tipsInfo = '服务器繁忙，请稍后重试';
  if (typeof (inputMsg) === 'object' && inputMsg.message){
    if(inputMsg.code == 0){
      return;
    }
    tipsInfo = inputMsg.message;
  } else if(typeof(inputMsg) === 'string') {
    tipsInfo = inputMsg;
  }
  wx.showToast({
    title: tipsInfo,
    icon: 'none'
  })
}